; 编译命令：
; nasm -f elf -o kernel.o kernel.asm
; nasm -f elf -o string.o string.asm
; nasm -f elf -o kliba.o kliba.asm
; gcc -c -o start.o start.c
; ld -s -Ttext 0x30400 -m elf_i386 -o kernel.bin kernel.o string.o start.o klib.o

SELECTOR_KERNEL_CS equ 8

extern cstart

extern gdt_ptr

[SECTION .bss]
StackSpace resb 2 * 1024
StackTop:

[section .text]

global _start


_start:
	mov esp, StackTop
	sgdt [gdt_ptr]
	call cstart
	lgdt [gdt_ptr]
	
	jmp SELECTOR_KERNEL_CS:csinit
	
csinit:
	push 0
	popfd
	
	hlt